package com.itheima.controller.backend.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class PackageController {

    @Autowired
    private StringRedisTemplate redisTemplate;

    @PostMapping("/savePackage")
    public String savePackage(@RequestBody List<String> imageUrls) {
        // 假设套餐数据插入数据库成功
        // 将图片名称保存到 Redis 的 used_images 集合中
        for (String imageUrl : imageUrls) {
            redisTemplate.opsForSet().add("used_images", imageUrl);
        }

        return "Package saved successfully";
    }
}